#ifndef GUIDEWIDGET_H
#define GUIDEWIDGET_H

#include <QWidget>
#include <QDialog>
//#include <QOverload>
#include "common.h"

class QLabel;
class QPushButton;
class QLineEdit;
class QButtonGroup;
class StepOne;
class StepTwo;
class StepAll;
class StepThree;
class StepFour;
class QStackedWidget;
class QRadioButton;
class QFrame;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QListWidget;
class QTableWidget;
class MyCombox;

enum GuideStatus
{
    StatusOne = 0,
    StatusTwo,
    StatusAll,
    StatusThree,
    StatusFour,
    StatusDone,
};

class GuideWidget : public QDialog
{
    Q_OBJECT
public:
    explicit GuideWidget(QDialog *parent = nullptr);
public slots:
    void SltBtnSub(int btn);

signals:

protected:
    void paintEvent(QPaintEvent *event);
private:
    int m_status = StatusOne;

    QLabel *lab_one;
    QLabel *lab_two;
    QLabel *lab_all;
    QLabel *lab_three;
    QLabel *lab_four;

    QPushButton *btn_previous;
    QPushButton *btn_next;
    QPushButton *btn_cancel;
    QButtonGroup *btn_group;

    QStackedWidget *set_widget;

    StepOne *one_widget;
    StepTwo *two_widget;
    StepAll *all_widget;
    StepThree *three_widget;
    StepFour *four_widget;

    void UpdateStatus();
    void initStatus();
    void changeDescribe();
    bool CheckValue();
    void updateFile();
};

//project path and name
class StepOne : public QWidget
{
friend GuideWidget;
    Q_OBJECT
public:
    explicit StepOne(QWidget *parent = nullptr);
private slots:
    void setPath(bool clecked);
private:
    QLabel *lab_describe;
    QLabel *lab_name;
    QLineEdit *line_name;
    QLabel *lab_path;
    QLineEdit *line_path;
    QPushButton *btn_select;
};

//select type
class StepTwo : public QWidget
{
friend GuideWidget;
    Q_OBJECT
public:
    explicit StepTwo(QWidget *parent = nullptr);
protected:
    bool eventFilter(QObject *watched, QEvent *event);
private:
    QLabel *lab_describe;
    QRadioButton *radio_map;
    QRadioButton *radio_lcd;

    QLabel *lab_width;
    QLineEdit *line_width;
    QLabel *lab_height;
    QLineEdit *line_height;
    QLabel *lab_station_num;
    QLineEdit *line_station_num;

    QCheckBox *checkbox_lcd_mirror;
    QCheckBox *checkbox_mirror;
    QCheckBox *checkbox_down;
    QCheckBox *next_time;

};

class LineSetWgt : public QWidget
{
friend GuideWidget;
friend StepAll;
    Q_OBJECT
public:
    explicit LineSetWgt(int, QWidget *parent = nullptr);
private:
    QLabel *lab_station_num;
    QLineEdit *line_station_num;

    QLabel *lab_begin_point;
    QLineEdit *line_begin_x;
    QLineEdit *line_begin_y;

    QLabel *lab_end_point;
    QLineEdit *line_end_x;
    QLineEdit *line_end_y;

    QLabel   *lab_staggered;
    MyCombox *combox_staggered;

    QLabel    *lab_name_offset;
    QLineEdit *line_name_offset;

    QGroupBox *group_line;

    int m_line_num;


};

//all
class StepAll : public QWidget
{
friend GuideWidget;
    Q_OBJECT
public:
    explicit StepAll(QWidget *parent = nullptr);
public slots:
    void add_item();
    void sub_item();
private:
    QLabel *lab_describe;

    QLabel *lab_station_num;
    QLineEdit *line_station_num;

    QLabel *lab_x;
    QLineEdit *line_x;

    QLabel *lab_y;
    QLineEdit *line_y;

    LineSetWgt *line_wgt;

    QLabel *lab_name_width;
    QLineEdit *line_name_width;
    QLabel *lab_line_width;
    QLineEdit *line_line_width;
    QLabel *lab_point_width;
    QLineEdit *line_point_width;
    QLabel *lab_name_height;
    QLineEdit *line_name_height;
    QLabel *lab_line_height;
    QLineEdit *line_line_height;
    QLabel *lab_point_height;
    QLineEdit *line_point_height;

    QLabel *lab_unequal_spacing_offset;
    QLineEdit *line_unequal_spacing_offset;

    QLabel *lab_station_interval;
    QLineEdit *line_station_interval;

    QLabel   *lab_staggered;
    MyCombox *combox_staggered;

    QPushButton *btn_add;
    QPushButton *btn_del;

    QListWidget *list_line;
};

//interval
class StepThree : public QWidget
{
    friend GuideWidget;
    Q_OBJECT
public:
    explicit StepThree(QWidget *parent = nullptr);
protected:
    bool eventFilter(QObject *watched, QEvent *event);
private:

    QLabel *lab_describe;

    QCheckBox *need_interval;

    QLabel *lab_begin_point;
    QLineEdit *line_begin_x;
    QLineEdit *line_begin_y;
    QLabel *lab_end_point;
    QLineEdit *line_end_x;
    QLineEdit *line_end_y;

    QLabel *lab_name_width;
    QLineEdit *line_name_width;
    QLabel *lab_line_width;
    QLineEdit *line_line_width;
    QLabel *lab_point_width;
    QLineEdit *line_point_width;
    QLabel *lab_name_height;
    QLineEdit *line_name_height;
    QLabel *lab_line_height;
    QLineEdit *line_line_height;
    QLabel *lab_point_height;
    QLineEdit *line_point_height;


    QLabel *lab_station_num;
    QLineEdit *line_station_num;
    QLabel *lab_cur_location;
    QLineEdit *line_cur_location;
    QLabel    *lab_staggered;
    QComboBox *combox_staggered_interval;
    QGroupBox *group_interval_route;
    QLabel *lab_station_offset;
    QLineEdit *line_station_offset;
    QLabel *lab_unequal_spacing_offset;
    QLineEdit *line_unequal_spacing_offset;
};

//project file
class StepFour : public QWidget
{
    friend GuideWidget;
    Q_OBJECT
public:
    explicit StepFour(QWidget *parent = nullptr);
    void addItem(QString);
    void updateFile();
private:
    QLabel *lab_describe;
    QListWidget *list_file;

};

#endif // GUIDEWIDGET_H
